{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "6628426e",
   "metadata": {},
   "source": [
    "-------\n",
    "* 课程：python语言\n",
    "* 时间：2023.10.09\n",
    "* week05\n",
    "-------"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e87236bc",
   "metadata": {},
   "source": [
    "# 1.用户输入\n",
    "> 1.input（）\n",
    ">\n",
    "> 2.inout输出的数据类型是：string 字符串"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "934c7e9c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "name:Nofear\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'Nofear'"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "input(\"name:\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "a7da42f6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入用户名：Nofear\n",
      "请输入密码：123456\n"
     ]
    }
   ],
   "source": [
    "# 用户注册\n",
    "username = input(\"请输入用户名：\")\n",
    "password = input(\"请输入密码：\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "caab1468",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Nofear\n"
     ]
    }
   ],
   "source": [
    "print(username)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3c149fd1",
   "metadata": {},
   "source": [
    "* 妙计：两个=是等于的意思，if后面要有空格"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "8e2340ae",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "账号或者密码不正确，请重新尝试！\n"
     ]
    }
   ],
   "source": [
    "# 用户登录\n",
    "if username == \"Nofear\" and password == \"123456\" :\n",
    "    print(\"欢迎来到王者峡谷，我是南京hero久竞无畏\")\n",
    "else:\n",
    "    print(\"账号或者密码不正确，请重新尝试！\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "61f333bd",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入用户名：zhichso\n",
      "请输入密码：123456\n",
      "账号或密码不正确，请重新尝试！！！\n"
     ]
    }
   ],
   "source": [
    "# 用户注册\n",
    "username = input(\"请输入用户名：\")\n",
    "password = input(\"请输入密码：\")\n",
    "# 用户登录\n",
    "if username == \"zhichao\" and password == \"123456\":\n",
    "    print(\"欢迎尊贵的VVVIP用户登录！！！\")\n",
    "else:\n",
    "    print(\"账号或密码不正确，请重新尝试！！！\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "af5eef2b",
   "metadata": {},
   "source": [
    "# 2.用户规范化/格式化输出"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "a8f76d31",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "输入你的姓名:qiqi\n",
      "输入你的年龄:20\n",
      "输入你的职业:IT\n",
      "输入你的薪资:1000000000\n",
      "----INFOqiqi-----\n",
      "姓名是: qiqi\n",
      "年龄是: 20\n",
      "工作是: IT\n",
      "薪资是: 1000000000\n"
     ]
    }
   ],
   "source": [
    "name = input(\"输入你的姓名:\")\n",
    "age = input(\"输入你的年龄:\")\n",
    "job = input(\"输入你的职业:\")\n",
    "salary = input(\"输入你的薪资:\")\n",
    "\n",
    "# info为展示的数据\n",
    "info = \"\"\"----INFO\"\"\" + name +\"\"\"-----\n",
    "姓名是: \"\"\" + name + \"\"\"\n",
    "年龄是: \"\"\" + age + \"\"\"\n",
    "工作是: \"\"\" + job + \"\"\"\n",
    "薪资是: \"\"\" + salary\n",
    "\n",
    "# 打印结果\n",
    "print(info)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "a90c9f64",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "输入你的姓名:胖胖\n",
      "输入你的年龄:20\n",
      "输入你的职业:英语\n",
      "输入你的薪资:1000000\n",
      "----INFO 胖胖----\n",
      "姓名是: 胖胖\n",
      "年龄是: 20\n",
      "工作是: 英语\n",
      "薪资是: 1000000\n"
     ]
    }
   ],
   "source": [
    "name = input(\"输入你的姓名:\")\n",
    "age = input(\"输入你的年龄:\")\n",
    "job = input(\"输入你的职业:\")\n",
    "salary = input(\"输入你的薪资:\")\n",
    "\n",
    "# info为展示的数据\n",
    "info = \"\"\"----INFO %s----\n",
    "姓名是: %s\n",
    "年龄是: %s\n",
    "工作是: %s\n",
    "薪资是: %s\"\"\"%(name,name,age,job,salary)\n",
    "\n",
    "# 打印结果\n",
    "print(info)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b09ca0bb",
   "metadata": {},
   "source": [
    "* 占位符\n",
    "> 1.顺序\n",
    ">\n",
    "> 2.%s代表字符串%d代表字（整数）%f代表小数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "97b5e7f2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "输入你的姓名:wdl\n",
      "输入你的年龄:19\n",
      "输入你的职业:档案\n",
      "输入你的薪资:1000000\n",
      "----INFO wdl----\n",
      "姓名是: wdl\n",
      "年龄是: 19\n",
      "工作是: 档案\n",
      "薪资是: 1000000\n"
     ]
    }
   ],
   "source": [
    "name = input(\"输入你的姓名:\")\n",
    "age = input(\"输入你的年龄:\")\n",
    "job = input(\"输入你的职业:\")\n",
    "salary = input(\"输入你的薪资:\")\n",
    "\n",
    "# info为展示的数据(前端)\n",
    "info = \"\"\"----INFO {N}----\n",
    "姓名是: {N}\n",
    "年龄是: {A}\n",
    "工作是: {J}\n",
    "薪资是: {S}\"\"\".format(N=name,J=job,S=salary,A=age) # 解决了占位符的顺序问题\n",
    "\n",
    "# 打印结果\n",
    "print(info)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f2794a60",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
